package agents;

import game.constants.ReferenceAgent;
import game.constants.ReferenceObject;
import game.constants.ReferenceSpecialFeature;
import interfaces.impl.Agent;

import java.util.ArrayList;

import objects.SpetialFeature;
import objects.WorldObject;
import universe.Universe;
import actions.ActionDropObject;
import actions.ActionGiveVespeneGas;

public class AgentGiveVespeneGas extends Agent{
	
	ActionDropObject actionDropObject;
	SpetialFeature timeToGiveVespeneGas;
	SpetialFeature vespeneGasQuantity;
	ActionGiveVespeneGas actionGiveVespeneGas;
	

	double contTime=0;
	@Override
	public void initializeActionList() {
		
		actionDropObject=new ActionDropObject();
		addAction(actionDropObject);
		
		actionGiveVespeneGas = new ActionGiveVespeneGas();
		addAction(actionGiveVespeneGas);
	}

	@Override
	public void initializeSpecialFeatures() {
		
		timeToGiveVespeneGas= new SpetialFeature(ReferenceSpecialFeature.SPETIAL_FEATURE_TIME_TO_GATHER_VESPENE_GAS);
		addSpetialFeature(timeToGiveVespeneGas);
		
		vespeneGasQuantity = new SpetialFeature(ReferenceSpecialFeature.SPETIAL_FEATURE_VESPENE_GAS_QUANTITY_TO_GATHER);
		addSpetialFeature(vespeneGasQuantity);
	}

	@Override
	public void initializeName() {
		name="Agent Give vespene Gas";
		
	}

	@Override
	public void initializeId() {
		id= ReferenceAgent.AGENT_GIVE_VESPENE_GAS;
		
	}

	@Override
	public void updateChild(WorldObject object, Universe universe, double time) {
		
		contTime+=time;
		if(contTime<timeToGiveVespeneGas.getValue()){
			return;
		}
		contTime=0;
		ArrayList<WorldObject> inventory = object.getListObjects();
		if(inventory.isEmpty()){
			return;
		}
		
		for(WorldObject obj :inventory){
			if(obj.getObjectReference()==ReferenceObject.OBJECT_REFERENCE_SVC1){
				actionDropObject = new ActionDropObject();
				actionDropObject.setSource(object);
				actionDropObject.setTarget(object);
				actionDropObject.setObjectToDrop(obj);
				actionDropObject.setOwner(object.getOwner());
				universe.setAction(actionDropObject);
				break;
			}
		}
		
		System.out.println("Suelto a la navecita");
		
		
		
	}
	
	

}
